package com.kyivmohyla.kma2.client.presenter;

import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.kyivmohyla.kma2.client.gin.Injector;
import com.kyivmohyla.kma2.shared.model.UIStaff;

public class LoginAllowViewPresenter implements Presenter {

    private final Display display;
    private final Injector injector = Injector.INSTANCE;

    @Inject
    public LoginAllowViewPresenter() {
        this.display = injector.getLoginAllowView();
    }

    public LoginAllowViewPresenter(UIStaff loginStaff) {
        this.display = injector.getLoginAllowView();
        this.display.getFirstName().setText(loginStaff.getFirstName());
        this.display.getLastName().setText(loginStaff.getLastName());
        this.display.getEmail().setText(loginStaff.getEmail());
        this.display.getPassword().setText(loginStaff.getPassword());
        this.display.getPositionId().setText(String.valueOf(loginStaff.getPositionId()));
    }

    @Override
    public void go(HasWidgets container) {
        container.clear();
        container.add(display.asWidget());
    }

    public interface Display {
        HasText getFirstName();

        HasText getLastName();

        HasText getEmail();

        HasText getPassword();

        HasText getPositionId();

        Widget asWidget();
    }

}
